package com.prs.crm.dao.archives.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.archives.WaitBorrowDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.archives.WaitBorrow;

public class WaitBorrowDaoImpl extends BaseDaoImpl<WaitBorrow> implements WaitBorrowDao{

	@Override
	public WaitBorrow getWaitBorrow(final String number, final Integer state) {
		Criteria criteria=this.getSession().createCriteria(WaitBorrow.class);
		criteria.add(Restrictions.eq("number", number));
		criteria.add(Restrictions.eq("state", state));
		List result=criteria.list();
		if (result==null || result.size()==0) {
			return null;
		}
		return (WaitBorrow) criteria.list().get(0);
	}

	@Override
	public WaitBorrow getWaitBorrows(final String number) {
		Criteria criteria=this.getSession().createCriteria(WaitBorrow.class);
		criteria.add(Restrictions.eq("number", number));
		List result=criteria.list();
		if (result==null || result.size()==0) {
			return null;
		}
		return (WaitBorrow) criteria.list().get(0);
	}

}
